//星星的数据处理
const app = getApp() 
function conver(stars){
  let num;
  if (Number(stars).toString().length<2){
    num = Number(stars).toString()
  }else{
    num = Number(stars).toString().substring(0, 1)
  }
  var starArr=[];
  for(let i=0;i<5;i++){
    if(i<num){
      starArr.push(1)
    }else{
      starArr.push(0)
    }
  }
  return starArr;
}

//截取字符串长度替换
function cut(title,start,ent){
  if(title.length>end){
    title=title.substring(start,end)+"..."
  }
  return title
}

function http(url, cak){
  var that = this;
  wx.request({
    url: url,
    data: {
      x: '',
      y: ''
    },
    method:"GET",
    header: {
      'content-type': 'application/json' // 默认值
    },
    success(res) {
      console.log(res)
      cak(res.data)
    }
  })
}

module.exports = {
  conver: conver,
  http: http,
  cut: cut
}


// const formatTime = date => {
//   const year = date.getFullYear()
//   const month = date.getMonth() + 1
//   const day = date.getDate()
//   const hour = date.getHours()
//   const minute = date.getMinutes()
//   const second = date.getSeconds()

//   return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
// }

// const formatNumber = n => {
//   n = n.toString()
//   return n[1] ? n : '0' + n
// }

// module.exports = {
//   formatTime: formatTime
// }
